var e = require("../../requests/request.js");

require("../../utils/util.js");

Page({
    data: {
        deviceid: "",
        array: [ "BUG类", "错误类", "吐槽类", "咨询类", "优化建立类", "其它" ],
        objectArray: [ {
            id: 0,
            name: "BUG类"
        }, {
            id: 1,
            name: "错误类"
        }, {
            id: 2,
            name: "吐槽类"
        }, {
            id: 3,
            name: "咨询类"
        }, {
            id: 4,
            name: "优化建立类"
        }, {
            id: 5,
            name: "其它"
        } ],
        index: -1,
        text_length: 0,
        userbacktype: "请选择",
        userbackcontent: "",
        userbackphone: "",
        loading: !1
    },
    onLoad: function(e) {
        this.setData({
            deviceid: e.OpenId
        });
    },
    onReady: function(e) {},
    onShow: function() {
        this.setData({
            index: -1,
            text_length: 0,
            userbacktype: "请选择",
            userbackcontent: "",
            userbackphone: ""
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    userfeedbacklist: function(e) {
        wx.navigateTo({
            url: "../userback/userback?deviceid=" + this.data.deviceid
        });
    },
    userphone: function(e) {
        this.setData({
            userbackphone: e.detail.value
        });
    },
    bindpickerchange: function(e) {
        var t = e.detail.value;
        this.setData({
            index: t,
            userbacktype: this.data.array[t]
        });
    },
    bindText: function(e) {
        var t = e.detail.value;
        this.setData({
            text_length: t.length,
            userbackcontent: t
        });
    },
    saveuserback: function() {
        var t = this;
        if ("请选择" != this.data.userbacktype) if ("" != this.data.userbackcontent) if (this.data.userbackphone.length > 25) wx.showModal({
            title: "",
            content: "联系方式长度应小于26",
            showCancel: !1
        }); else {
            var a = this.data.deviceid, n = "", i = "", s = "", c = "";
            wx.getSystemInfo({
                success: function(e) {
                    n = e.model, c = e.screenHeight + "*" + e.screenWidth, s = e.version, i = e.system;
                }
            }), e.addUserFeedback(a, n, i, s, "wifi", c, "中国联通", "1.0", this.data.userbackphone, this.data.userbacktype, this.data.userbackcontent, function(e) {
                2 == e.Status ? wx.navigateTo({
                    url: "../userback/userback?deviceid=" + a
                }) : wx.showToast({
                    title: "提交失败！"
                });
            }, null, function() {
                t.setData({
                    loading: !1
                });
            });
        } else wx.showToast({
            title: "请添加补充说明"
        }); else wx.showToast({
            title: "请选择反馈类型"
        });
    }
});